package com.group2.bankonline.mapper;

import com.group2.bankonline.pojo.Transrecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author syf
 * @since 2024-07-11
 */
public interface TransrecordMapper extends BaseMapper<Transrecord> {
    @Select("""
            select * from transrecord where accountid = #{id} or otherid = #{id};
            """)
    public List<Transrecord> selectByAidOrOid(@Param("id") int id);

    @Select("""
            select * from transrecord where (accountid = #{id} or otherId = #{id}) and transtypeid = #{transtypeId};
            """)
    public List<Transrecord> selectByType(@Param("id") int id,@Param("transtypeId")int transtypeId);

    @Select("""
            select * from transrecord where (accountid = #{id} or otherid = #{id}) and money between #{money1} and #{money2};
            """)
    public List<Transrecord> selectByMoney(@Param("id") int id,@Param("money1") int money1,@Param("money2") int money2);

    @Select("""
            select * from transrecord where (accountid = #{id} or otherid = #{id}) and transdate = #{Date};
            """)
    public List<Transrecord> selectByDate(@Param("id")int id,@Param("Date") String date);


    @Select("""
            select * from transrecord where accountid = #{aid} and otherid = #{oid};
            """)
    public List<Transrecord> selectByAidAndOid(@Param("aid") int aid,@Param("oid")int oid);

    public void saveRecord(Transrecord transrecord);
}
